package homework08;

import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;

public class homework001 {
	public static void main(String[] args) throws Exception {
		FileReader fr=new FileReader("homework08001.txt");
		StringBuilder sb=new StringBuilder();
		int ch;
		while((ch=fr.read())!=-1){
			sb.append((char)ch);
		}
		fr.close();
		System.out.println(sb);
		String str=sb.toString();
		String[] arrStr=str.split("-");
		ArrayList<Integer> list=new ArrayList<>();
		for (String s:arrStr){
			int i=Integer.parseInt(s);
			list.add(i);			
		}
		Collections.sort(list);
		System.out.println(list);
		FileWriter fw=new FileWriter("homework08001.txt");
		for (int i=0;i<list.size();i++){
			if (i==list.size()-1){
				fw.write(list.get(i)+"");
			}else{
				fw.write(list.get(i)+"-");
			}
		}
		fw.close();
	}
}
